package com.liuhuxiang.order.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/***
 * @Author liuhuxiang
 */
@Service
public class OrderSericeImpl implements IOrderService {

    /***
     * 这里是将业务方法定义成为资源，针对业务方法进行流控降级
     * 注意：使用了SentinelResource，全局的异常注解就不会生效了，要自己定义blockHandler来声明
     * @return
     */
    @Override
    @SentinelResource(value="getUser",blockHandler = "blockHandlerGetUser")
    public String getUser() {
        return "查询用户";
    }

    public String blockHandlerGetUser(BlockException e) {
        return "流控用户";
    }
}
